package com.xiaolun.other;


import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Demo11 {
	public static void main(String[] args) throws Exception {
		cacheStreamDemo02();
		return;
	}

	private static void cacheStreamDemo02() throws IOException {
		String separator = File.separator;
		File file = new File("D:" + separator + "test" + separator + "test3.txt");
		FileInputStream input = new FileInputStream(file);
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		byte[] data = new byte[1024];
		int length = 0;
		while ((length = input.read(data)) != -1){
			//将数据保存到内存输出流中
			output.write(data, 0, length);
		}
		//获取全部的内容
		System.out.println(new String(output.toByteArray()));
		output.close();
		input.close();
	}
}
